<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
  <!-- <script src="https://lib.baomitu.com/vue-router/3.5.2/vue-router.js"></script> -->
  <script src="./my-router.js"></script>
</head>

<body>
  <div id="app">
    <router-link to="/home">home</router-link>
    <router-link to="/login">login</router-link>

    <router-view></router-view>
  </div>

</body>

<script>
  const Home = {
    name: 'Home',
    template: `
      <div><h1>Home</h1></div>
    `
  }

  const Login = {
    name: 'Login',
    template: `
      <div><h1 style="color: red;">Login</h1></div>
    `
  }

  Vue.use(MyRouter);
  const router = new MyRouter({
    routes: [{
        path: '/home',
        component: Home,
      },
      {
        path: '/login',
        component: Login,
      },
    ]
  });

  const app = new Vue({
    el: '#app',
    router,
  });

</script>

</html>
